package com.sojoys.artifact.tools;

import com.sojoys.artifact.core.IServer;
import com.sojoys.artifact.exception.AbstractLogicModelException;
import com.sojoys.artifact.exception.LogicModelDevException;
import com.sojoys.artifact.exception.LogicModelProException;

/**
 * @author : DengYing
 * @CreateDate : 2017年7月28日 下午5:44:31
 * @Description ：逻辑异常工具类
 */
public class ToolError {

	public static AbstractLogicModelException newLogicError(final int errorCode) {
		if (IServer.getConstants().isDevMode())
			return new LogicModelDevException(errorCode);
		else
			return new LogicModelProException(errorCode);
	}

	public static AbstractLogicModelException newLogicError(final int errorCode, final String message) {
		if (IServer.getConstants().isDevMode())
			return new LogicModelDevException(errorCode, message);
		else
			return new LogicModelProException(errorCode, message);
	}

	public static void isAndTrue(final int errorCode, final String message, final boolean bool) {
		if (bool) {
			throw newLogicError(errorCode, message);
		}
	}
	
	public static void isAndTrue(final int errorCode, final boolean bool) {
		if (bool) {
			throw newLogicError(errorCode);
		}
	}
	// public static void isAndTrue(final int errorCode, final String message,
	// final boolean...expression) {
	// if (BooleanUtils.and(expression)) {
	// throw newLogicError(errorCode, message);
	// }
	// }
	//
	// public static void isAndTrue(final int errorCode, final
	// boolean...expression) {
	// if (BooleanUtils.and(expression)) {
	// throw newLogicError(errorCode);
	// }
	// }
	//
	// public static void isOrTrue(final int errorCode, final String message,
	// final boolean...expression) {
	// if (BooleanUtils.or(expression)) {
	// throw newLogicError(errorCode);
	// }
	// }
	//
	// public static void isOrTrue(final int errorCode, final
	// boolean...expression) {
	// if (BooleanUtils.or(expression)) {
	// throw newLogicError(errorCode);
	// }
	// }
}
